import 'package:flutter/material.dart';
import 'package:splash_login/common/assets.dart';
import 'package:splash_login/common/button.dart';
import 'package:splash_login/pages/login.dart';

class WelcomePage extends StatelessWidget {
  const WelcomePage({super.key});

  Widget _buildBtns(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: Row(
        children: [
          // skip
          TextButton(
              onPressed: () {},
              child: const Text(
                'Skip',
                style: TextStyle(
                    fontSize: 15,
                    color: Color(0xff2B2A2A),
                    fontWeight: FontWeight.w300),
              )),
          // 弹开
          const Spacer(),
          // get started
          ButtonWidget(
            text: 'Get Started',
            width: 139,
            height: 42,
            onPressed: () => Navigator.push(context,
                MaterialPageRoute(builder: (context) => const LoginPage())),
          )
        ],
      ),
    );
  }

  Widget _buildText() {
    return const Padding(
      padding: EdgeInsets.symmetric(horizontal: 38),
      child: Text(
        'Browse & Order All Products at Any Time',
        style: TextStyle(
            fontSize: 20,
            fontWeight: FontWeight.bold,
            color: Color(0xff2B2A2A),
            height: 23 / 20),
      ),
    );
  }

  Widget _buildView(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        // 标题
        _buildText(),
        const SizedBox(
          height: 70,
        ),
        // 图片
        Image.asset(
          AssetsImages.welcomePng,
          height: 409,
          width: double.infinity,
          fit: BoxFit.fitWidth,
        ),
        // 按钮组
        const SizedBox(
          height: 70,
        ),
        _buildBtns(context)
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _buildView(context),
    );
  }
}
